﻿namespace Guia.Elements
{
    using System.Diagnostics.Contracts;
    using System.Windows.Automation;
    using Guia.Core;

    /// <summary>
    /// This interface represents a window. It contains all relevant functionalities for all kind of windows.
    /// This interface is necessary, because there are various kind of window-like componentes which should all follow the same interface.
    /// </summary>
    [ContractClass(typeof(WindowContracts))]
    public interface IWindow : IUiElement
    {
        /// <summary>
        /// Gets the open MessageBox instance with the given name as title.
        /// </summary>
        /// <param name="name">The name of the MessageBox.</param>
        /// <returns>The MessageBox with the given title.</returns>
        MessageBox GetMessageBox(string name);

        /// <summary>
        /// Gets the SaveFileDialog instance of this window with the given name as title.
        /// </summary>
        /// <param name="name">The name of the SaveFileDialog.</param>
        /// <returns>The SaveFileDialog with the given title.</returns>
        SaveFileDialog GetSaveFileDialog(string name);

        /// <summary>
        /// Gets the SaveFileDialog of this window with the default-title.
        /// </summary>
        /// <returns>The default-titled SaveFileDialog.</returns>
        SaveFileDialog GetSaveFileDialog();

        /// <summary>
        /// Gets the OpenFileDialog instance of this window with the given name as title.
        /// </summary>
        /// <param name="name">The name of the OpenFileDialog.</param>
        /// <returns>The OpenFileDialog with the given title.</returns>
        OpenFileDialog GetOpenFileDialog(string name);

        /// <summary>
        /// Gets the OpenFileDialog of this window with the default-title.
        /// </summary>
        /// <returns>The default-titled OpenFileDialog.</returns>
        OpenFileDialog GetOpenFileDialog();

        /// <summary>
        /// Maximizes the window.
        /// </summary>
        /// <exception cref="OperationNotSupportedException">If maximizing is not supported in the current context.</exception> 
        void Maximize();

        /// <summary>
        /// Closes the window.
        /// </summary>
        void Close();

        /// <summary>
        /// Minimizes the window.
        /// </summary>
        /// <exception cref="OperationNotSupportedException">If minimizing is not supported in the current context.</exception> 
        void Minimize();

        /// <summary>
        /// Recovers the normal window-size. 
        /// </summary>
        void RecoverNormal();

        /// <summary>
        /// Get the window's visual state.
        /// </summary>
        /// <returns>The current visual state of the window</returns>
        WindowVisualState GetVisualState();

        /// <summary>
        /// Get the menu with the given automationId.
        /// </summary>
        /// <param name="automationId">The automationId of the desired Menu</param>
        /// <returns>A Menu instance.</returns>
        Menu GetMenu(string automationId);
    }
}
